package com.helloworld.demo.threadbase;

public class JoinTest {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("begin...");
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("end...");
            }
        });
        long start = System.currentTimeMillis();
        thread.start();
        //主线程等待线程子线程执行完成
        thread.join();

        System.out.println("执行时间：" + (System.currentTimeMillis()-start));
    }

}
